#pragma once
#include <string.h>
#include <vector>
#include "..\render\render.h"
#include "..\..\CommLib\CommStructs.h"
#include "..\..\Global\globaldef.h"

typedef void* HMATERIAL;

class Materials {

	struct tMaterial {

		uint type;
		byte* pData;
	};

	static std::vector<tMaterial*> g_Materials;

	static bool initalizeMaterial(uint type, byte* pData, tMaterial *pMaterial);
	static uint getTypeSize(uint type);
public:
	static bool Create(HMATERIAL* pOut);
	static bool UpdateMaterials(uint materialType, byte* pMaterialData, HMATERIAL pHandle);	
	static bool Release(HMATERIAL handle);

	static bool WriteToDisk(const std::string& filename, HMATERIAL handle);
	static bool ReadFromDisk(const std::string& filename, HMATERIAL* pOut);

	static bool ApplyToShader(Render::tShader *pShader, const std::string& channel, HMATERIAL handle);

};